package com.yu.rabbitmq.three;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;
import com.yu.rabbitmq.utils.RabbitMqUnits;

import java.io.IOException;
import java.util.Scanner;
import java.util.concurrent.TimeoutException;

/**
 * 持久化队列
 */
public class PersistenceProducer {

    
    public static final String TASK_QUEUE_NAME = "PS_queue";

    public static void main(String[] args) {
        try {
            Channel channel = RabbitMqUnits.getChannel();
            //声明队列
            channel.queueDeclare(TASK_QUEUE_NAME,true,false,false,null);
            channel.basicPublish("",TASK_QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN,"这个队列是持久化的".getBytes());
            System.out.println("消息发送完成");

        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }

    }
}
